NAME Statement ---------------------------------------------------------------------------- Action Changes the name of a disk file or directory. Syntax NAME oldfilespec$ AS newfilespec$ Remarks The NAME statement is similar to the DOS RENAME command. NAME can move a file from one directory to another but cannot move a directory. The arguments oldfilespec$ and newfilespec$ are string expressions, each of which contains a filename and an optional path. If the path in newfilespec$ is different from the path in oldfilespec$, the NAME statement renames the file as indicated. The file oldfilespec$ must exist and newfilespec$ must not be in use. Both files must be on the same drive. If you use NAME with different drive designations in the old and new filenames, BASIC generates the error message Rename across disks. Using NAME on an open file causes BASIC to generate the run-time error message File already open. You must close an open file before renaming it. Example The following example shows how to use NAME to rename a README.DOC file. CLS ' Clear screen. 'Change README.DOC to READMINE.DOC NAME "README.DOC" AS "READMINE.DOC" FILES ' Display the files in your directory to confirm name change. PRINT PRINT "README.DOC is now called READMINE.DOC" PRINT "Press any key to continue" DO LOOP WHILE INKEY$ = "" ' Change name back to README.DOC and confirm by displaying files. NAME "READMINE.DOC" AS "README.DOC" FILES PRINT PRINT "README.DOC is back to its original name" You also can use NAME to move a file from one directory to another. You can move README.DOC to the directory \MYDIR with the following statement. NAME "README.DOC" AS "\MYDIR\README.DOC"